home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / nn.zip / MATCH.C < prev    next >
C/C++ Source or Header  |  1989-06-28  |  2KB  |  73 lines

  1. #define    NUL    '\0'
  2. #define    NULL    ((char *)0)
  3.  
  4.  
  5. #ifdef notdef
  6.  
  7. /* use this table for creating input to the match.h routines */
  8.  
  9. char match_xxx[128] = {
  10.     
  11. /*  NUL SOH STX ETX EOT ENQ ACK BEL BS  TAB NL  VT  FF  CR  SO  SI  */
  12.     00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 
  13.  
  14. /*  DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM  SUB ESC FS  GS  RS  US  */
  15.     00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 
  16.  
  17. /*  SP  !   "   #   $   %   &   '   (   )   *   +   ,   -   .   /   */
  18.     00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 
  19.  
  20. /*  0   1   2   3   4   5   6   7   8   9   :   ;   <   =   >   ?   */
  21.     00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 
  22.  
  23. /*  @   A   B   C   D   E   F   G   H   I   J   K   L   M   N   O   */
  24.     00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 
  25.  
  26. /*  P   Q   R   S   T   U   V   W   X   Y   Z   [   \   ]   ^   _   */
  27.     00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 
  28.  
  29. /*  `   a   b   c   d   e   f   g   h   i   j   k   l   m   n   o   */
  30.     00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 
  31.  
  32. /*  p   q   r   s   t   u   v   w   x   y   z   {   |   }   ~   DEL */
  33.     00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00
  34.  
  35. };
  36. #endif
  37.  
  38.  
  39. /*
  40.  * the following routines only works for ASCII !!!!
  41.  *
  42.  * they are a quick hack to check for the occurrence of a word
  43.  * (regardless of case) in a string
  44.  */
  45.  
  46. #define UNIFY 040
  47.  
  48. init_quick_match(mask)
  49. char *mask;
  50. {
  51.     register char *m;
  52.  
  53.     for (m = mask; *m; m++) *m |= UNIFY;
  54. }
  55.  
  56. char *quick_match(subject, mask)
  57. register char *subject;
  58. char *mask;
  59. {
  60.     register char *q, *m;
  61.     register char m1 = *mask;
  62.  
  63.     for (; *subject; subject++) {
  64.         if ((*subject | UNIFY) != m1) continue;
  65.  
  66.         q = subject; m = mask;
  67.         do
  68.             if (*++m == NUL) return subject;
  69.         while ((*++q | UNIFY) == *m); 
  70.     }
  71.     return NULL;
  72. }
  73.